import request from '@/utils/request.js'

export const confirmOrder = (cartId, type) => {
  return request({
    method: 'POST',
    url: '/order/confirm',
    data: {
      cartId, // 要结算的购物车项目 ID，多个 ID 以逗号连接，如 1,2,3
      new: type, // 表示订单类型，0 表示购物车结算订单，1 表示立即购买订单
    },
  })
}

export const createOrder = (orderKey, addressId, payType) => {
  return request({
    method: 'POST',
    url: `/order/create/${orderKey}`,
    data: {
      addressId,
      payType,
    },
  })
}

export const getOrders = () => {
  return request({
    method: 'GET',
    url: `/order/list`
  })
}
